<!DOCTYPE html>
<html>
<head>
	<title>document</title>
	<meta charset="utf-8">
	<script type="text/javascript">
		var m =new Date - 0;
		document.write(m);
	</script>
	<style type="text/css">
	
	</style>
</head>
<body>
<DIV style="FONT-SIZE: 12px">打算利用这几天看得 服务, 线程TLS API, 同步和STL写一个应用程序, 作为服务在后台执行, 检测指定路径的文件变化, 把修改过的匹配查询表达式的文件进行备份, 这样就有一个文件查询和名称匹配, 正则表达式自然是最好的解决方法. 不过VC里面竟然不如VBS对于Regular Expression那样有支持, 除非升级到VC.NET, 我到CodeProject上面查询找到了相关解决方案:<BR><BR>&nbsp;&nbsp;其实VBS也是使用了微软自己REGEX的一个COM, 称为 "Microsoft VBScript Regular Expression 5.5" 我打开OleViewer找到了相关信息. 下面是那篇文章的使用例子<BR><BR>#import "RegExp.tlb" no_namespace<BR>...<BR>try {<BR>&nbsp;&nbsp;static IRegExpPtr regExp( __uuidof(RegExp) );<BR>&nbsp;&nbsp;regExp-&gt;Pattern = _bstr_t(lpszPattern);<BR><BR>&nbsp;&nbsp;HWND hWndCtrl = pDX-&gt;PrepareEditCtrl(nIDC);<BR>&nbsp;&nbsp;if (pDX-&gt;m_bSaveAndValidate)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int nLen = ::GetWindowTextLength(hWndCtrl);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;::GetWindowText(hWndCtrl, value.GetBufferSetLength(nLen),nLen+1);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value.ReleaseBuffer();<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//now we verify it<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( regExp-&gt;Test( (LPCTSTR)value) )<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IMatchCollectionPtr matches=regExp-&gt;Execute((LPCTSTR)value);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( matches-&gt;Count== 1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IMatchPtr match = matches-&gt;Item[0];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( match-&gt;FirstIndex==0 &amp;&amp; match-&gt;Length == value.GetLength() )<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CString strMsg = CString("The input does not exactly have the pattern ") + lpszPattern;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pDX-&gt;m_pDlgWnd-&gt;MessageBox(strMsg);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pDX-&gt;PrepareEditCtrl(nIDC);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pDX-&gt;Fail();<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;else<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;}<BR>}<BR>catch (_com_error&amp; e)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;AfxMessageBox( e.ErrorMessage() );<BR>}<BR>这样操作就简单多了, 不过对于COM这东西, 我倒是情愿到<A href="http://www.boost.org/" target=_blank>http://www.boost.org</A>下载一个类库, 不过不知道能不能使用在VC上面 </DIV>

</body>
</html>